﻿/*
 * File: MainMenuScene.cs
 * Author: Gourav Das
 * Purpose: Load and show main menu
 * Created: April 2011
 * Copyright: Gourav Das, 2011
 */

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using _22yards._2D;
using _22yards.Scenes.Helpers;
namespace _22yards.Scenes
{
    /// <summary>
    /// This is a Scene that implements MainMenuScene.
    /// </summary>
    class MainMenuScene : BaseMenuScene
    {
        public MainMenuScene()
            : base("Main Menu - 22 Yards")
        {
            // Create our menu entries.
            MenuItem CareerMenuItem = new MenuItem("Career",0);
            MenuItem BattlegroundMenuItem = new MenuItem("Battleground",1);
            MenuItem OnlineMenuItem = new MenuItem("Online - Not Implemented",2);
            MenuItem LoadGameMenuItem = new MenuItem("Load Game",3);
            MenuItem GameCustomizationMenuItem = new MenuItem("Game Customization",4);
            MenuItem OptionMenuItem = new MenuItem("Options",5);
            MenuItem exitMenuEntry = new MenuItem("Exit",6,false,true);

            // Hook up menu event handlers.
            CareerMenuItem.Selected += CareerMenuItem_Selected;
            BattlegroundMenuItem.Selected += BattlegroundMenuItem_Selected;
            OnlineMenuItem.Selected += OnlineMenuItem_Selected;
            LoadGameMenuItem.Selected += LoadGameMenuItem_Selected;
            GameCustomizationMenuItem.Selected += GameCustomizationMenuItem_Selected;
            OptionMenuItem.Selected += OptionMenuItem_Selected;
            exitMenuEntry.Selected += OnCancel;

            // Add entries to the menu.
            MenuItems.Add(CareerMenuItem);
            MenuItems.Add(BattlegroundMenuItem);
            MenuItems.Add(OnlineMenuItem);
            MenuItems.Add(LoadGameMenuItem);
            MenuItems.Add(GameCustomizationMenuItem);
            MenuItems.Add(OptionMenuItem);
            MenuItems.Add(exitMenuEntry);
        }


        /// <summary>
        /// Event handler for when the Career Menu Item is selected.
        /// </summary>
        void CareerMenuItem_Selected(object sender, PlayerIndexEventArgs e)
        {
            //LoadingScreen.Load(sceneEngine, true, e.PlayerIndex,
            //                   new CareerSceneBase());
            LoadingScene.Load(sceneEngine, true, PlayerIndex.One, new GamePlayBaseScene());
        }

        /// <summary>
        /// Event handler for when the Battleground menu Item is selected.
        /// </summary>
        void BattlegroundMenuItem_Selected(object sender, PlayerIndexEventArgs e)
        {
            ExitScene();
            sceneEngine.AddScene(new TopBattlegroundMenuScene(), e.PlayerIndex);
        }

        /// <summary>
        /// Event handler for when the Online menu Item is selected.
        /// </summary>
        void OnlineMenuItem_Selected(object sender, PlayerIndexEventArgs e)
        {
            //LoadingScene.Load(sceeneEngine, true, e.PlayerIndex,
            //                   new OnlineSceneBase());
        }

        /// <summary>
        /// Event handler for when the Load Game menu item is selected.
        /// </summary>
        void LoadGameMenuItem_Selected(object sender, PlayerIndexEventArgs e)
        {
            //LoadingScene.Load(sceneEngine, true, e.PlayerIndex,
            //                   new LoadGameScene());
        }

        /// <summary>
        /// Event handler for when the Game Customization menu item is selected.
        /// </summary>
        void GameCustomizationMenuItem_Selected(object sender, PlayerIndexEventArgs e)
        {
            //LoadingScene.Load(sceneEngine, true, e.PlayerIndex,
            //                   new GameCustomizationScene());
        }

        /// <summary>
        /// Event handler for when the Options menu item is selected.
        /// </summary>
        void OptionMenuItem_Selected(object sender, PlayerIndexEventArgs e)
        {
            //sceneEngine.AddScene(new OptionsMenuScene(), e.PlayerIndex);
        }


        /// <summary>
        /// When the user cancels the main menu, ask if they want to exit the Game.
        /// </summary>
        protected override void OnCancel(PlayerIndex _playerIndex)
        {
            const string msg = "Are you sure you want to exit 22Yards?";

            MsgBoxScreen confirmExitMsgBox = new MsgBoxScreen(msg);
            confirmExitMsgBox.Accepted += ConfirmExitMessageBoxAccepted;

            sceneEngine.AddScene(confirmExitMsgBox, _playerIndex);
        }


        /// <summary>
        /// Event handler for when the user selects ok on the "are you sure
        /// you want to exit" message box.
        /// </summary>
        void ConfirmExitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
        {
            ExitScene();
            sceneEngine.Game.Exit();
        }
    }

}
